#ifndef _GENERIC_TYPE_
#define _GENERIC_TYPE_

#define TPOBJ 0
#define TPCHAR 1
#define TPTR 2
#define TCHAR 3
#define TSHORT 4
#define TINT 5
#define TLONG 6
#define TLONGLONG 7
#define TFLOAT 8
#define TDOUBLE 9
#define TLONGDOUBLE 10

typedef union
{
	void *vptr;
	char vchar;
	short vshort;
	int vint;
	long vlong;
	long long vlonglong;
	float vfloat;
	double vdouble;
	long double vlongdouble;
} GenericVal;

typedef struct
{
	int type;
	GenericVal val;
} GenericType;

#define VSET0(VAL) val.vptr = (void *)VAL
#define VSET1(VAL) val.vptr = (void *)VAL
#define VSET2(VAL) val.vptr = (void *)VAL
#define VSET3(VAL) val.vchar = VAL
#define VSET4(VAL) val.vshort = VAL
#define VSET5(VAL) val.vint = VAL
#define VSET6(VAL) val.vlong = VAL
#define VSET7(VAL) val.vlonglong = VAL
#define VSET8(VAL) val.vfloat = VAL
#define VSET9(VAL) val.vdouble = VAL
#define VSET10(VAL) val.vlongdouble = VAL

#define VGET0 val.vptr
#define VGET1 val.vptr
#define VGET2 val.vptr
#define VGET3 val.vchar
#define VGET4 val.vshort
#define VGET5 val.vint
#define VGET6 val.vlong
#define VGET7 val.vlonglong
#define VGET8 val.vfloat
#define VGET9 val.vdouble
#define VGET10 val.vlongdouble

#define VSETn(TYPE) VSET##TYPE
#define VSET(TYPE,VAL) VSETn(TYPE) (VAL)

#define VGETn(TYPE) VGET##TYPE
#define VGET(TYPE) VGETn(TYPE)

#endif

